#pragma once

class ShaderParameter
{
public:
	ShaderParameter() : mBinded(false) {}
	ShaderParameter(size_t reg) : mBinded(true), mStartRegister(reg) {}

	bool getBinded() const { return mBinded; }
	size_t getStartRegister() const { return mStartRegister; }

	bool Bind(class Shader* shader, const std::string& param);

	void SetVertexShaderValue(float value) const;
	void SetVertexShaderValue(const Vector4& value) const;
	void SetVertexShaderValue(const Matrix& value) const;

	void SetPixelShaderValue(float value) const;
	void SetPixelShaderValue(const Vector4& value) const;
	void SetPixelShaderValue(const Matrix& value) const;

	static void SetVertexShaderValue(size_t reg, const float* value, size_t num);
	static void SetPixelShaderValue(size_t reg, const float* value, size_t num);

private:
	bool mBinded;
	size_t mStartRegister;
};

inline void ShaderParameter::SetVertexShaderValue(float value) const
{
	Vector4 alignValue(value);
	if (mBinded)
		SetVertexShaderValue(mStartRegister, alignValue.Ptr(), 1);
}

inline void ShaderParameter::SetVertexShaderValue(const Vector4& value) const
{
	if (mBinded)
		SetVertexShaderValue(mStartRegister, value.Ptr(), 1);
}

inline void ShaderParameter::SetVertexShaderValue(const Matrix& value) const
{
	if (mBinded)
		SetVertexShaderValue(mStartRegister, value.Ptr(), 4);
}

inline void ShaderParameter::SetPixelShaderValue(float value) const
{
	Vector4 alignValue(value);
	if (mBinded)
		SetPixelShaderValue(mStartRegister, alignValue.Ptr(), 1);
}

inline void ShaderParameter::SetPixelShaderValue(const Vector4& value) const
{
	if (mBinded)
		SetPixelShaderValue(mStartRegister, value.Ptr(), 1);
}

inline void ShaderParameter::SetPixelShaderValue(const Matrix& value) const
{
	if (mBinded)
		SetPixelShaderValue(mStartRegister, value.Ptr(), 4);
}
